/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-02-24 17:26:15
 * @LastEditTime: 2024-02-25 19:17:33
 * @FilePath: /react-vite-admin/src/store/settings/index.ts
 */
import { makeAutoObservable } from "mobx"
import { makePersistable } from "mobx-persist-store"

class Settings {
    isOpen: boolean = true//侧边栏是否展开
    tagShow: boolean = false//标签页是否显示
    layout: string = 'vertical' //整体框架布局 vertical 侧边栏 horizontal 顶部+侧边栏 top顶部+下拉页面
    logoPosition: string = 'top'//logo所属组件位置 top side
    theme: string = 'default'//主题 default light blue ...

    constructor() {
        //自动观察
        makeAutoObservable(this, {}, { autoBind: true });
        //持久化存储
        makePersistable(this, {
            name: 'Settings',
            properties: ['isOpen', 'tagShow', 'layout', 'logoPosition', 'theme'],
            storage: window.localStorage
        })
    }

    //侧边栏是否展开
    setOpen = () => {
        this.isOpen = !this.isOpen;
    }
    //标签页是否显示
    setTag = () => {
        this.tagShow = !this.tagShow;
    }
    //更改布局
    setLayout = (layout: string) => {
        this.layout = layout;
    }
    //更改logo显示位置
    setLogoPosition = (position: string) => {
        this.logoPosition = position;
    }
    //更改主题
    setTheme = (theme: string) => {
        this.theme = theme;
    }
}

export default Settings;